var searchMatrix = function(matrix, target) {
    let sum = matrix.length * matrix[0].length
    let left = 0
    let right = sum - 1
    let row = matrix.length
    let col = matrix[0].length
    while (left <= right) {
        let midIndex = Math.floor((left + right) / 2)
        let currentRow = Math.floor(midIndex / col)
        let currentCol = midIndex % col
        let mid = matrix[currentRow][currentCol]
        if (mid === target) {
            return true
        }
        if (target < mid) {
            right = midIndex - 1
        } else {
            left = midIndex + 1
        }
    }
    return false
};
console.log(searchMatrix([
    [1, 4, 5, 6, 7]
], -1))